package genetic.q2;


import genetic.Genotype;

public class PrisonerInspectionGenotype implements Genotype{

	public int memory;
	private int strategy;
	public PrisonerInspectionGenotype(int strategy){
		this.strategy = strategy;
	}

	public PrisonerInspectionGenotype(){

	}

	public PrisonerInspectionGenotype clone(){
		PrisonerInspectionGenotype g = new PrisonerInspectionGenotype(strategy);
		return g;
	}

	@Override
	public String toString() {
		String ans ="";
		switch (strategy){
		case 1:
			ans = "always betrayal";
		case 2:
			ans = "always cooperate";
		case 3:
			ans = "Tit for Tat";
		}
		return ans;
	}

	@Override
	public int[] getIntString() {
		// TODO Auto-generated method stub
		return null;
	}

	public void update(int turn, boolean f, boolean s) {
		memory = 0;
		if(s) memory = 1;
	}

	public boolean returnChoise(int turn) {
			if(turn==0){
				switch (strategy){
				case 1:
					return false;
				case 2:
					return true;
				case 3:
					return true;
				}
			}
			else{
				switch (strategy){
				case 1:
					return false;
				case 2:
					return true;
				case 3:
					if(memory==1)
						return true;
					return false;
				}
			}
			return true;
	}

}
